<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<link href="css/admin/form/prerelate.css" rel="stylesheet" type="text/css" />
<div style="width:100%">
<button id="startInit">设置字段</button>
</div>
<div id="mainpanl" align="center">
<ol id="workflowName" class="selectable2">
		  <c:forEach items="${workflowNames}" var="workflow">
			<li class="ui-widget-content" 
			    wname="${workflow}">${workflow}</li>
		  </c:forEach>
        </ol>
<ol id="template" class="selectable2">
  <c:forEach items="${htmlTemplates}" var="temp">
       <li  class="ui-widget-content" tname="${temp.name}" tid="${temp.id}">
           ${temp.name}
       </li>
  </c:forEach>
</ol>       
</div>
 <div id='workflowresult'></div>
<script type="text/javascript">
var wname='';
var tid='';
$(function(){
	 $("#workflowName").selectable({
			stop: function(event,ui){
				
				//var workflow = this.get(0);
				//alert(ui);
				//result.append(workflow.val());			
			},
			selected: function(event, ui) {
				var sel  = ui['selected'];
				var result = $("#workflowresult");
		        //debugObject(sel);
				//alert(sel.textContent);
				var name = sel.attributes["wname"]["value"];
				result.empty();
				result.append("您选择的工作流是:" + name);
				wname  = name;
		    }
			
		
	 });
	 $("#template").selectable({
			stop: function(event,ui){
				
				//var workflow = this.get(0);
				//alert(ui);
				//result.append(workflow.val());			
			},
			selected: function(event, ui) {
				var sel  = ui['selected'];
				var result = $("#workflowresult");
		        //debugObject(sel);
				//alert(sel.textContent);
				var name = sel.attributes["tname"]["value"];
				var id = sel.attributes["tid"]["value"];
				result.empty();
				result.append("您选择的表单是:" + name);
				tid  = id;
		    }
			
		
	 });
	 
	 $("#startInit").click(function(){
		 startinit();
	 }).button();
 });
 function startinit(){
   	 if(wname=='' || tid==''){
		return confirm('请选择工作流/模版');
     } 
   	 var param = {"workflowName.workflowName":wname,"htmlTemplate.id":tid};
     var url= "admin/field/field-manager!init";
   	 doPost(url,$.param(param));  
  
}
</script>
